import context.Order;
import service.IPaymentStrategy;
import service.impl.AlipayStrategy;
import service.impl.CreditCardStrategy;
import service.impl.WechatPayStrategy;

/**
 * 策略模式演示类
 */
public class StrategyPatternDemo {
    public static void main(String[] args) {
        // 创建一个订单，金额为999.99元
        Order order = new Order(999.99);

        System.out.println("=== 策略模式演示：多种支付方式 ===");
        
        // 场景1：用户选择支付宝支付
        System.out.println("\n1. 支付宝支付:");
        IPaymentStrategy alipay = new AlipayStrategy("zhangsan@alipay.com");
        order.setPaymentStrategy(alipay);
        order.executePayment();

        // 场景2：用户切换到微信支付
        System.out.println("\n2. 微信支付:");
        IPaymentStrategy wechatPay = new WechatPayStrategy("wx_openid_123456");
        order.setPaymentStrategy(wechatPay);
        order.executePayment();

        // 场景3：用户切换到信用卡支付
        System.out.println("\n3. 信用卡支付:");
        IPaymentStrategy creditCard = new CreditCardStrategy("1234567812345678", "123");
        order.setPaymentStrategy(creditCard);
        order.executePayment();
        
        // 场景4：使用便捷方法
        System.out.println("\n4. 使用便捷方法支付:");
        order.payWithAlipay("lisi@alipay.com");
    }
}